/*
** Author mi_kuncoco@yahoo.co.id
*/
function Preloader(){
	this.numToLoad = 0;
	this.started = false;
};
Preloader.prototype = {
	constructor:Preloader,
	numToLoad : 0,
	callback : null,
	started : false,
	loadImage : function(imageUrl) {
		this.numToLoad = (this.numToLoad < 1) ? 1 : (this.numToLoad + 1);
		var ret = new Image();
		ret.onload = preloader.itemLoaded();
		ret.src = imageUrl;
		return ret;
	},
	checkIfComplete : function(e){
		if (this.callback == null) return false;
		if (this.numToLoad < 1) {
			this.callback();
			this.dispose();
		}
	},
	itemLoaded : function(){
		this.numToLoad--;
		if (this.started) this.checkIfComplete();
	},
	start : function(){
		this.started = true;
		this.checkIfComplete();
	},
	dispose:function(){
		callback = null;
		preloader = null;
	}
};

var preloader = new Preloader();
